﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Reflection;
using Common.Logging;
using plas.core;

namespace plas.cps.ui
{
     #if DEBUG
    public partial class AbstractForm : OfficeForm
#else
    public abstract partial class AbstractForm : OfficeForm
#endif
    {
        protected ILog logger;

        public AbstractForm()
        {
            InitializeComponent();
            logger = ApplicationHandler.GetLogger(this.GetType());
            //this.ControlBox = false;

        }

        public void bindCommand(ButtonX button)
        {
            Type t = this.GetType();
            FieldInfo f = t.GetField((string)button.Tag, BindingFlags.Instance | BindingFlags.NonPublic);
            if (f != null)
            {
                object cmd = f.GetValue(this);
                if (cmd is DevComponents.DotNetBar.Command)
                {
                    button.Command = (DevComponents.DotNetBar.Command)cmd;
                    button.Enabled = true;
                    return;
                }
            }
            button.Enabled = false;
        }
    }
}
